<?php

namespace App\Services\Statistics;

use AlibabaCloud\SDK\Dingtalk\Vdrive_1_0\Models\GetPreviewInfoResponseBody\info;
use Carbon\Carbon;
use App\Models\User;
use App\Models\Order;
use App\Models\Comment;
use App\Models\Product;
use App\Models\ProductSku;
use App\Models\GoldCharge;
use App\Models\GoldRecord;
use App\Models\OrderRefund;
use App\Models\Vippurchase;

class HardCount
{
	
	/*---------- users -------------------------------------------------------------------------------------------------*/


	/** total_users_count_now */
	public function totalUsersCountNow()
	{
		return User::select()->count();
	}

	/** total_normal_users_count_now */
	public function totalNormalUsersCountNow()
	{
		return User::select()->where('grade', 'normal')->count();
	}

	/** total_normal_users_count_today */
	public function totalNormalUsersCountToday()
	{
		return User::select()->where('grade', 'normal')
			->whereDate('created_at', Carbon::today())
			->count();
	}

	/** total_normal_users_count_back1_day */
	public function totalNormalUsersCountBack1Day()
	{
		return User::select()->where('grade', 'normal')
			->whereDate('created_at', Carbon::today()->addDays(-1))
			->count();
	}

	/** total_normal_users_count_back2_day */
	public function totalNormalUsersCountBack2Day()
	{
		return User::select()->where('grade', 'normal')
			->whereDate('created_at', Carbon::today()->addDays(-2))
			->count();
	}

	/** total_normal_users_count_back3_day */
	public function totalNormalUsersCountBack3Day()
	{
		return User::select()->where('grade', 'normal')
			->whereDate('created_at', Carbon::today()->addDays(-3))
			->count();
	}

	/** total_normal_users_count_back4_day */
	public function totalNormalUsersCountBack4Day()
	{
		return User::select()->where('grade', 'normal')
			->whereDate('created_at', Carbon::today()->addDays(-4))
			->count();
	}

	/** total_vip_users_count_now */
	public function totalVipUsersCountNow()
	{
		return User::select()->where('grade', 'vip')->count();
	}

	/** total_vip_users_count_today */
	public function totalVipUsersCountToday()
	{
		return Vippurchase::select()->whereNotNull('paid_at')
			->whereDate('created_at', Carbon::today())
			->count();
	}

	/** total_vip_users_count_back1_day */
	public function totalVipUsersCountBack1Day()
	{	
		return Vippurchase::select()->whereNotNull('paid_at')
			->whereDate('created_at', Carbon::today()->addDays(-1))
			->count();
		
	}

	/** total_vip_users_count_back2_day */
	public function totalVipUsersCountBack2Day()
	{
		return Vippurchase::select()->whereNotNull('paid_at')
			->whereDate('created_at', Carbon::today()->addDays(-2))
			->count();
	}

	/** total_vip_users_count_back3_day */
	public function totalVipUsersCountBack3Day()
	{
		return Vippurchase::select()->whereNotNull('paid_at')
			->whereDate('created_at', Carbon::today()->addDays(-3))
			->count();
	}

	/** total_vip_users_count_back4_day */
	public function totalVipUsersCountBack4Day()
	{
		return Vippurchase::select()->whereNotNull('paid_at')
			->whereDate('created_at', Carbon::today()->addDays(-4))
			->count();
	}
}
